using Arcane.Source.Utils;

namespace Arcane.Source
{
    public abstract class ViewContext<V> : IContext
        where V: IView
    {
        public abstract string ViewName { get; }

        protected V View { get; set; }

        public GameOS Os { get; set; }

        public virtual bool PreventBack => false;

        public virtual void OnTick() { }

        public virtual void OnLoad(Msg msg)
        {
            View = (V)Os.LoadView(ViewName);
        }

        public virtual void OnPause() { }

        public virtual void OnResume(Msg msg)
        {
            Os.MountView(View);
        }

        public virtual void OnUnload()
        {
            Os.TryUnmountView(View);

            View.QueueFree();
        }
    }
}